package pl.com.kyhu.dietex3000.GUI.dialogs;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

public class HelpDialog extends Dialog {

	protected Object result;
	protected Shell shell;

	public HelpDialog(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	private void createContents() {
		shell = new Shell(getParent(), SWT.SHELL_TRIM | SWT.BORDER);
		shell.setSize(443, 520);
		shell.setText(getText());
		
		Label titleLabel = new Label(shell, SWT.NONE);
		titleLabel.setFont(SWTResourceManager.getFont("Microsoft Sans Serif", 35, SWT.NORMAL));
		titleLabel.setBounds(114, 26, 186, 60);
		titleLabel.setText("POMOC");
		
		Label helpLabel = new Label(shell, SWT.WRAP);
		helpLabel.setBounds(58, 111, 328, 276);
		helpLabel.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed convallis eu ante quis scelerisque. Proin in metus ut mi tempus eleifend et sit amet nibh. Suspendisse ut nisl non odio imperdiet tincidunt. Fusce viverra a magna id tempus. Aenean dignissim elementum justo. Sed at iaculis neque. Aliquam id pellentesque massa. Cras volutpat, sapien at ultrices adipiscing, dui lectus elementum ligula, ut elementum justo mauris nec purus. Nam pellentesque elementum eros, vel auctor quam mattis nec. Vivamus posuere est orci, vel iaculis mi placerat vel. Nunc dictum elementum sem, eu rutrum massa suscipit ac. Vestibulum et massa nec justo feugiat fringilla.\r\n\r\nEtiam lectus odio, sagittis eu tincidunt sed, egestas pellentesque elit. Phasellus tincidunt nulla sit amet nisl rhoncus, at pellentesque ante adipiscing. Etiam ornare accumsan lorem ac volutpat. Vivamus non tortor eu velit pharetra elementum. Aliquam adipiscing dolor non dapibus vestibulum. Praesent mollis erat sed est scelerisque eleifend et sed sem.dictum, sed fermentum risus bibendum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae lacus malesuada, sagittis leo nec.");
		
		Button okButton = new Button(shell, SWT.NONE);
		okButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				shell.close();
			}
		});
		okButton.setBounds(172, 393, 83, 34);
		okButton.setText("OK");

	}

}
